package ttp.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import ttp.to.ChemicalTO;
import ttp.to.CrushTO;
import ttp.to.CuttingTO;
import ttp.to.DryingTO;
import ttp.to.TreeTO;
import ttp.utilities.DatabaseUtil;

public class TtpDAO {
	private DatabaseUtil dbUtil;
	private static TtpDAO instance = new TtpDAO();

	private TtpDAO(){
		dbUtil = DatabaseUtil.getInstance();
	}
	public static TtpDAO getInstance(){
		return instance;
	}
	
	public int sequenceTree() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int sequence = 0;
		String sql = "select tree_no_seq.nextval from dual";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			while(rset.next()){
			sequence = rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return sequence;
	}
	
	public int sequenceCrush() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int sequence = 0;
		String sql = "select crush_no_seq.nextval from dual";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			while(rset.next()){
			sequence = rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return sequence;
	}
	
	public int sequenceChemical() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int sequence = 0;
		String sql = "select chemical_no_seq.nextval from dual";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			while(rset.next()){
			sequence = rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return sequence;
	}
	
	public int sequenceDrying() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int sequence = 0;
		String sql = "select drying_no_seq.nextval from dual";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			while(rset.next()){
			sequence = rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return sequence;
	}
	
	public int sequenceCutting() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int sequence = 0;
		String sql = "select cutting_no_seq.nextval from dual";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			while(rset.next()){
			sequence = rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return sequence;
	}
	
	public int insertTree(TreeTO tto) throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "insert into trees (tree_no, enterprise, tree_type, tree_grade, tree_count, order_date, tree_check, error_rate, result) values(?,?,?,?,?,?,?,?,?)";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, tto.getTreeNo());
			pstmt.setString(2, tto.getEnterPrise());
			pstmt.setString(3, tto.getTreeType());
			pstmt.setString(4, tto.getTreeGrade());
			pstmt.setInt(5, tto.getTreeCount());
			pstmt.setString(6, tto.getOrderDate());
			pstmt.setInt(7, tto.getTreeCheck());
			pstmt.setInt(8, tto.getErrorRate());
			pstmt.setInt(9, tto.getResult());
			
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	
	public int insertCrush(CrushTO cto) throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "insert into Crush (crush_no, enterprise, tree_type, tree_grade, tree_weight, product_date, crush_check, error_rate, result) values(?,?,?,?,?,?,?,?,?)";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1,  cto.getCrushNo());
			pstmt.setString(2, cto.getEnterPrise());
			pstmt.setString(3, cto.getTreeType());
			pstmt.setString(4, cto.getTreeGrade());
			pstmt.setInt(5, cto.getTreeWeight());
			pstmt.setString(6, cto.getProductDate());
			pstmt.setInt(7, cto.getCrushCheck());
			pstmt.setInt(8, cto.getErrorRate());
			pstmt.setInt(9, cto.getResult());
			
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	
	public int insertChemical(ChemicalTO cmto) throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "insert into chemical (chemical_no, enterprise, tree_type, tree_grade, pulp_weight, product_date, chemical_check, error_rate, result) values(?,?,?,?,?,?,?,?,?)";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, cmto.getChemicalNo());
			pstmt.setString(2, cmto.getEnterPrise());
			pstmt.setString(3, cmto.getTreeType());
			pstmt.setString(4, cmto.getTreeGrade());
			pstmt.setInt(5, cmto.getPulpWeight());
			pstmt.setString(6, cmto.getProductDate());
			pstmt.setInt(7, cmto.getChemicalCheck());
			pstmt.setInt(8, cmto.getErrorRate());
			pstmt.setInt(9, cmto.getResult());
			
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	
	public int insertDrying(DryingTO dto) throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "insert into Drying (drying_no, enterprise, tree_type, tree_grade, paper_weight, product_date, drying_check, error_rate, result) values(?,?,?,?,?,?,?,?,?)";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, dto.getDryingNo());
			pstmt.setString(2, dto.getEnterPrise());
			pstmt.setString(3, dto.getTreeType());
			pstmt.setString(4, dto.getTreeGrade());
			pstmt.setInt(5, dto.getPaperWeight());
			pstmt.setString(6, dto.getProductDate());
			pstmt.setInt(7, dto.getDryingCheck());
			pstmt.setInt(8, dto.getErrorRate());
			pstmt.setInt(9, dto.getResult());
			
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	
	public int insertCutting(CuttingTO cuto) throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "insert into cutting (cutting_no, enterprise, tree_type, tree_grade, paper_count, product_date, cutting_check, error_rate, result) values(?,?,?,?,?,?,?,?,?)";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, cuto.getCuttingNo());
			pstmt.setString(2, cuto.getEnterPrise());
			pstmt.setString(3, cuto.getTreeType());
			pstmt.setString(4, cuto.getTreeGrade());
			pstmt.setInt(5, cuto.getPaperCount());
			pstmt.setString(6, cuto.getProductDate());
			pstmt.setInt(7, cuto.getCuttingCheck());
			pstmt.setInt(8, cuto.getErrorRate());
			pstmt.setInt(9, cuto.getResult());
			
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	
	public int updateTree(int treeNo) throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update trees set result=result+1 where tree_No=?";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, treeNo);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	
	public int updateCrush(int CrushNo) throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update Crush set result=result+1 where crush_no=?";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, CrushNo);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	
	public int updateChemical(int ChemicalNo) throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update Chemical set result=result+1 where chemical_no=?";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, ChemicalNo);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	
	public int updateDrying(int DryingNo) throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update Drying set result=result+1 where drying_no=?";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, DryingNo);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	
	public int updateCutting(int CuttingNo) throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update Cutting set result=result+1 where cutting_no=?";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, CuttingNo);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public TreeTO selectTreeByNo(int result)throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		TreeTO tto = null;
		String sql = "select tree_no, enterprise, tree_type, tree_grade, tree_count, order_date, tree_check, error_rate, result from (select rownum rm, tree.* from (select * from trees where result = ? order by tree_no asc) tree) where rm=1";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, result);
			rset = pstmt.executeQuery();
			while(rset.next()){
				tto = new TreeTO(rset.getInt(1), rset.getString(2), rset.getString(3), rset.getString(4), rset.getInt(5),
						rset.getString(6), rset.getInt(7),rset.getInt(8),rset.getInt(9));
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return tto;
	}
	
	public CrushTO selectCrushByNo(int result)throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		CrushTO cto = null;
		String sql = "select crush_no, enterprise, tree_type, tree_grade, tree_weight, product_date, crush_check, error_rate, result from (select rownum rm, crush.* from (select * from crush where result = ? order by crush_no asc) crush) where rm=1";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, result);
			rset = pstmt.executeQuery();
			while(rset.next()){
				cto = new CrushTO(rset.getInt(1), rset.getString(2), rset.getString(3), rset.getString(4), rset.getInt(5),
						rset.getString(6), rset.getInt(7),rset.getInt(8),rset.getInt(9));
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cto;
	}
	
	public ChemicalTO selectChemicalByNo(int result)throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		ChemicalTO cmto = null;
		String sql = "select chemical_no, enterprise, tree_type, tree_grade, pulp_weight, product_date, chemical_check, error_rate, result from (select rownum rm, chemical.* from (select * from chemical where result = ? order by chemical_no asc) chemical) where rm=1";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, result);
			rset = pstmt.executeQuery();
			while(rset.next()){
				cmto = new ChemicalTO(rset.getInt(1), rset.getString(2), rset.getString(3), rset.getString(4), rset.getInt(5),
						rset.getString(6), rset.getInt(7),rset.getInt(8),rset.getInt(9));
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cmto;
	}
	
	public DryingTO selectDryingByNo(int result)throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		DryingTO dto = null;
		String sql = "select drying_no, enterprise, tree_type, tree_grade, paper_weight, product_date, drying_check, error_rate, result from (select rownum rm, drying.* from (select * from drying where result = ? order by drying_no asc) drying) where rm=1";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, result);
			rset = pstmt.executeQuery();
			while(rset.next()){
				dto = new DryingTO(rset.getInt(1), rset.getString(2), rset.getString(3), rset.getString(4), rset.getInt(5),
						rset.getString(6), rset.getInt(7),rset.getInt(8),rset.getInt(9));
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return dto;
	}
	
	public CuttingTO selectCuttingbyNo(int result)throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		CuttingTO cuto = null;
		String sql = "select cutting_no, enterprise, tree_type, tree_grade, paper_count, product_date, cutting_check, error_rate, result from (select rownum rm, cutting.* from (select * from cutting where result = ? order by cutting_no asc) cutting) where rm=1";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, result);
			rset = pstmt.executeQuery();
			while(rset.next()){
				cuto = new CuttingTO(rset.getInt(1), rset.getString(2), rset.getString(3), rset.getString(4), rset.getInt(5),
						rset.getString(6), rset.getInt(7),rset.getInt(8),rset.getInt(9));
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cuto;
	}
	//상태값 가져오기
	public int selectCrushStatus()throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int cnt=0;
		String sql = "select status from Crushss";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			if(rset.next()){
				cnt=rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int selectChemicalStatus()throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int cnt=0;
		String sql = "select status from chemicalss";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			if(rset.next()){
				cnt=rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int selectDryingStatus()throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int cnt=0;
		String sql = "select status from Dryingss";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			if(rset.next()){
				cnt=rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int selectCuttingStatus()throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int cnt=0;
		String sql = "select status from cuttingss";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			if(rset.next()){
				cnt=rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	// 스탑값 가져오기
	public int selectTreeStop()throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int cnt=0;
		String sql = "select stop from treess";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			if(rset.next()){
				cnt=rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int selectCrushStop()throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int cnt=0;
		String sql = "select stop from crushss";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			if(rset.next()){
				cnt=rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int selectChemicalStop()throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int cnt=0;
		String sql = "select stop from chemicalss";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			if(rset.next()){
				cnt=rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int selectDryingStop()throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int cnt=0;
		String sql = "select stop from dryingss";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			if(rset.next()){
				cnt=rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int selectCuttingStop()throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rset = null;
		int cnt=0;
		String sql = "select stop from Cuttingss";
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			rset = pstmt.executeQuery();
			if(rset.next()){
				cnt=rset.getInt(1);
			}
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	//상태값 바꾸기
	public int updateCrushStatus0() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update crushss set status=0";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateCrushStatus1() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update crushss set status=1";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateChemicalStatus0() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update chemicalss set status=0";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateChemicalStatus1() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update chemicalss set status=1";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateDryingStatus0() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update dryingss set status=0";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateDryingStatus1() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update dryingss set status=1";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateCuttingStatus0() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update cuttingss set status=0";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateCuttingStatus1() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update cuttingss set status=1";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	//정지 값 바꾸기
	public int updateTreeStop0() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update treess set stop=0";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateTreeStop1() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update treess set stop=1";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateCrushStop0() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update crushss set stop=0";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateCrushStop1() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update crushss set stop=1";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateChemicalStop0() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update chemicalss set stop=0";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateChemicalStop1() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update chemicalss set stop=1";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateDryingStop0() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update Dryingss set stop=0";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateDryingStop1() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update Dryingss set stop=1";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateCuttingStop0() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update Cuttingss set stop=0";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
	public int updateCuttingStop1() throws Exception{
		Connection conn = null;
		PreparedStatement pstmt = null;
		int cnt = 0;
		String sql = "update Cuttingss set stop=1";  
		try{
			conn = dbUtil.getConnection();
			pstmt = conn.prepareStatement(sql);
			cnt = pstmt.executeUpdate();
		}finally{
			dbUtil.close(conn, pstmt);
		}
		return cnt;
	}
}
